﻿using WebBanHang.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PagedList;
using PagedList.Mvc;

namespace WebBanHang.Controllers
{
    public class LayoutController : Controller
    {
        HNCSolutionsEntities db = new HNCSolutionsEntities();

        public ActionResult _Menu()
        {
            HNCSolutionsEntities container = new HNCSolutionsEntities();

            return PartialView(container.Menus.Where(mn => mn.TrangQuanTri.HasValue && !mn.TrangQuanTri.Value).ToList());
        }

        public PartialViewResult _SlideshowBanner()
        {
            Banner bannerTrangChu = new Banner { Action = "Index", Controller = "Home", ImagePath = "/Images/Website/banner_2.gif" };
            Banner bannerGioiThieu = new Banner { Action = "About", Controller = "Home", ImagePath = "/Images/Website/banner3.jpg" };
            Banner bannerLienHe = new Banner { Action = "Index", Controller = "ThietBiVoIP", ImagePath = "/Images/Website/VoIPBanner.jpg" };

            return PartialView(new List<Banner> { bannerTrangChu, bannerGioiThieu, bannerLienHe });
        }

        public PartialViewResult _MenuChinh()
        {
            return PartialView();
        }

        public PartialViewResult _LinkFooter()
        {
            return PartialView();
        }

        public PartialViewResult _TinTuc(int soluongTin = 10)
        {
            var model = this.db.TinTucs.Take(soluongTin).ToList();
            return PartialView(model);
        }

        public PartialViewResult _TinTucKhac(int id = 0, int soluongTin = 10)
        {            
            var model = this.db.TinTucs.Where(tt => tt.Id != id).Take(soluongTin).ToList();
            return PartialView(model);
        }

        public PartialViewResult _SanPhamTieuBieu()
        {
            return PartialView();
        }

        #region Left
        public PartialViewResult _LogoQuangCao(bool leftside)
        {
            var listNhomSanPham = db.NhomSanPhams.OrderBy(nsp => nsp.ThuTu);
            return PartialView(listNhomSanPham);
        }

        public PartialViewResult _NhomSanPhamSideBox()
        {
            var listNhomSanPham = db.NhomSanPhams.OrderBy(nsp => nsp.ThuTu);
            return PartialView(listNhomSanPham);
        }
        #endregion

        #region Center
        public PartialViewResult _SanPhamMoi(int? page)
        {
            var sanPhams = this.db.SanPhams.ToList();
            return PartialView("_DanhSachSanPhamMainBox", sanPhams.ToPagedList(page ?? 1, 5));
        }
        #endregion

        #region Right
        public PartialViewResult _HoTroTrucTuyen()
        {
            var hoTroTrucTuyens = this.db.HoTroTrucTuyens;            
            return PartialView(hoTroTrucTuyens);
        }

        public PartialViewResult _HuongDanSuDung()
        {
            return PartialView();
        }

        public PartialViewResult _ThietKeWeb()
        {
            return PartialView();
        }
        #endregion

        public PartialViewResult _ThongKeTruyCap()
        {
            return PartialView();
        }
    }
}
